package cn.jaye.fabric.application;

import cn.jaye.fabric.common.constant.MicroConstant;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import cn.jaye.fabric.domain.service.RestTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Jaye
 * @create 2018-01-09 13:09
 */
@Service
public class ServiceApplicationService {

    @Autowired
    private RestTemplateService restTemplateService;

    @Autowired
    private MicroConstant microConstant;


    private static final String APIAUTHORIZE_SERVICE_NAME = "apiauthorize";

    public String listService() {
        String url = microConstant.getApiGatewayAddress() + APIAUTHORIZE_SERVICE_NAME + "/service/list";
        JSONObject postData = new JSONObject();
        JSONObject resultObject = restTemplateService.getUrlResponse(url, postData);
        return JSON.toJSONString(resultObject);
    }
}
